import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForMaskedLM
from transformers import DebertaV2Config
from transformers import pipeline

if __name__ == '__main__':
    model_name = './IDEA-CCNLErlangshen-Roberta-110M-Sentiment'
    # 加载配置并修正分类数

    tokenizer = AutoTokenizer.from_pretrained(model_name)
    model = AutoModelForSequenceClassification.from_pretrained(model_name)
    text = '大消费概念全线走强'
    print(model.config.id2label)  # 查看数字到类名的映射
    output = model(torch.tensor([tokenizer.encode(text)]))
    print(torch.nn.functional.softmax(output.logits, dim=-1))